FacebookTwitterLinkedInHere is how you can remove all empty spaces from a string using JavaScript. var str = "T u toria l s Pa n el. co m"; var newStr = str.replace(/\s+/g, ''); alert(newStr); More JavaScript Snippets Shuffle an Array using JavaScript Remove the Last Character from a String using JavaScript Select a Random Item from an Array using JavaScript